import {
  getRequest
} from "./HttpRequest";

let config = require("@/config.js").config;


const menuList = [
  {
    id: 1,
    perName: "首页",
    parentId: 0,
    parentName: '',
    router: '/admin/index',
    icon: 'el-icon-s-home',
    href: '',
    sort: '',
    type: 2,
    role: "admin|user",
    outJoin: false,
    children: []
  },
  {
    id: 2,
    perName: "支付管理",
    parentId: 0,
    parentName: '',
    router: '',
    icon: 'el-icon-s-home',
    href: '',
    sort: '',
    type: 1,
    role: "",
    outJoin: false,
    children: [
      {
        id: 3,
        perName: "支付宝网站支付",
        parentId: 2,
        parentName: '',
        router: '/admin/pay/index',
        icon: 'el-icon-s-home',
        href: '',
        sort: '',
        type: 2,
        role: "",
        outJoin: false,
        children: [
          {}
        ]
      }
    ]
  },
];

// 获取菜单
export const getMenus = (callback) => {

  if (config.useServerMenu) {
    let list = [config.routerIndex];
    getRequest("/permission/userMenuTree", {}).then((res) => {
      if (res.R) {
        let menus = res.data;
        for (let i = 0; i < menus.length; i++) {
          let menu = menus[i];
          list.push(menu);
        }
        callback(list);
      }
    });
    return;
  }
  callback(menuList);
}
